# 导入模块
from common.send_method import *
import jsonpath
# 创建一个接口类
class GetMessage:

  @staticmethod
  # 查询顾客的的方法
  def getmessage(cookie,url,data):
    headers = cookie
    try:
      # 发送请求
      #调用send_menthod方法请求数据
      result = SenMethod.send_method(method='post',url=url,data=data,headers=headers)
      print(result.json())
    except Exception as e:
      pass

    # 检查点
    try:
      result2 = jsonpath.jsonpath(result.json(),'$..cid')
      print(result2)
      print('接口正常')
      print('查询成功')
    except Exception as e:
      print('未正常返回')
      print("查询失败")
      result2 = False
    return  result2

  @staticmethod
  def getmessage1(cookie, url,data):
    headers = cookie
    try:
      # 发送请求
      # 调用send_menthod方法请求数据
      result = SenMethod.send_method(method='post', url=url, data=data, headers=headers)
      print(result.json())
    except Exception as e:
      pass

    # 检查点
    try:
      result2 = jsonpath.jsonpath(result.json(), '$..aid')
      print(result2)

      print('接口正常')
      print('查询成功')
    except Exception as e:
      print('未正常返回')
      print("查询失败")
      result2 = False
    return result2

    if result2:
        result2 = True
        print('接口正常')
    else:
        print('未正常返回')



if __name__ == '__main__':
    cookie = api_login('admin',12345)
    url = 'http://kumanxuan1.f3322.net:8096/MMS/Client/GetClient'
    data = {'cno': '1529'}
    GetMessage.getmessage(cookie,url,data)
    url1 = 'http://kumanxuan1.f3322.net:8096/MMS/Agency/GetAgency'
    data1 = {'ano': '10106824'}
    GetMessage.getmessage1(cookie,url1,data1)

